{include file="common@public/_category" /}
<!--container-->
  <div class="container container-gary">
      <!-- member index -->
      <div class="m-ptb wrap clearfix">
          {include file="common@public/_personal_left"}
          <div class="member-right">
              <div class="member-sign clearfix"><b>安全管理</b></div>
              <div class="member-order min-height">
                  <div class="member-t-gary clearfix">
                      <h3>邮箱地址修改</h3>
                  </div>
                  <form id="form" action="{:url('member/member/changeemail')}" method="POST">
                    <div class="m-safe-info">
                        <div class="m-safe-enter clearfix">
                            <div class="m-safe-txt">手机号码：</div>
                            <div class="m-safe-right">
                                <div class="safe-right-text"><span>{$Think.session.mobile}</span><span class="safe-prompt">如手机已不用或丢失，请联系平台客户确认身份</span></div>
                            </div>
                        </div>
                        <div class="m-safe-enter clearfix">
                            <div class="m-safe-txt">验证码：</div>
                            <div class="m-safe-right">
                                <input class="safe-input" type="text" placeholder="请输入短信验证码" name="telverify" id="telverify"/>
                                <input class="safe-btn" id="btnSendCode" onclick="sendMessage()" type="button" value="获取短信验证码" />
                            </div>
                        </div>
                        <div class="m-safe-enter clearfix">
                            <div class="m-safe-txt">新邮箱地址：</div>
                            <div class="m-safe-right">
                                <input class="safe-input safe-w1" type="text" placeholder="请输入新邮箱地址" name="new_email" id="new_email"/>
                            </div>
                        </div>
                        <div class="m-safe-enter clearfix">
                            <div class="m-safe-txt">确认邮箱地址：</div>
                            <div class="m-safe-right">
                                <input class="safe-input safe-w1" type="text" placeholder="请再次输入新邮箱地址" id="emailconfirm"/>
                            </div>
                        </div>
                        <input type="hidden" name="checkverify" id="checkverify" value="{$check_verify}" />
                        {eq name="$check_verify" value="1"}
                            <div class="m-safe-enter clearfix">
                                <div class="m-safe-txt">输入验证码：</div>
                                <div class="m-safe-right">
                                    <input class="safe-input" type="text" placeholder="请输入验证码" name="verify" id="verify" />
                                    <div class="safe-code"><img src="{:captcha_src()}" alt="captcha" style="height: 48px" title="点击刷新" class="reloadverify verifyimg"/></div>
                                </div>
                            </div>
                        {/eq}
                        <div class="m-safe-enter clearfix">
                            <div class="m-safe-txt"></div>
                            <div class="m-safe-right">
                                <input type="hidden" name="mobile" id="mobile" value="{$Think.session.mobile}" />
                                <input class="safe-btn1 safe-b-color" type="submit" value="确认" id="but"/><input class="safe-btn1" type="reset" value="取消"/>
                            </div>
                        </div>
                    </div>
                  </form>
              </div>
          </div>
      </div>

  </div>

  <!-- footer -->
  <!--#include file="includes/foot.html"-->

<!-- menu -->
<script type="text/javascript" src="/public/static/home/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/public/static/home/js/menu.js"></script>
<script src="/public/static/home/js/sendverify.js"></script>
<script>
    $(function() {
      $('#form').submit(function() {
           var mobile=$('#mobile');
           var telverify=$('#telverify');
           var new_email=$('#new_email');
           var emailconfirm=$('#emailconfirm');
           var verify=$('#verify');
           var checkverify=$('#checkverify');

            if(telverify.val()==''){
                alert("请输入手机短信验证码");
                telverify.focus();
                return false;
            }else if(new_email.val()==''){
                alert("请输入新邮箱地址");
                new_email.focus();
                return false;
            }else if(emailconfirm.val()==''){
                alert("请输入确认新邮箱地址");
                emailconfirm.focus();
                return false;
            }else if(emailconfirm.val()!=new_email.val()){
                alert("新邮箱地址两次输入不正确");
                emailconfirm.focus();
                return false;
            }else if(verify.val()==''&&checkverify.val()=='1'){
                alert("请输入验证码");
                verify.focus();
                return false;
            }else{
               $.ajax({
                    url:"{:url('member/member/changeemail')}",
                    type:"post",
                    data:$("#form").serialize(),
                    success:function (data) {
                        if(data.code==200){
                            window.location.href="{:url('member/member/save')}";
                        }else{
                            if(checkverify.val()=='1'){
                                var verifyimg = $(".verifyimg").attr("src");
                                if (verifyimg.indexOf('?') > 0) {
                                    $(".verifyimg").attr("src", verifyimg + '&random=' + Math.random());
                                } else {
                                    $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
                                }
                                $("#verify").focus();
                            }
                            alert(data.msg);
                        }
                    },
                    error: function(err, data) {
                        console.log(err); 
                    }
                });
                return false;
           }
       });
      //top select
      $(".top-select").mouseover(function () {
        $(".top-s-text").show();
      })
      $(".top-select").mouseout(function () {
        $(".top-s-text").hide();
      })
      $(".top-s-text div").click(function () {
        var selecttext = $(this).text();
        $(".top-s-head span").text(selecttext);
        $(this).parent(".top-s-text").hide()
      })
      // top code
      var turn = function(target,time,opts){
      target.find('.top-code').hover(function () {
            $(this).find('.top-c-img').stop().animate(opts[0], time, function () {
			$(this).hide().next().show();
			$(this).next().animate(opts[1],time);
	   });
	   },function(){
	        $(this).find('.top-c-text').animate(opts[0], time, function () {
			    $(this).hide().prev().show();
			    $(this).prev().animate(opts[1],time);
		 });
	     });
        }
        var verticalOpts = [{'width':0},{'width':'80px'}];
        turn($('.top-right'), 150, verticalOpts);
        //menu all
        $(".menu-all div").mouseenter(function () {
            $(this).addClass("current");
            $(".submenu").show();
        })
       $(".menu-all div").mouseleave(function () {
            $(this).removeClass("current");
            $(".submenu").hide();
        })
        $(".submenu").mouseenter(function(){
           $(this).show();
           $(".menu-all div").addClass("current")
        })
        $(".submenu").mouseleave(function(){
           $(this).hide();
           $(".menu-all div").removeClass("current")
        })
        //left submenu
        $(".submenu ul li").each(function () {
            var $this = $(this);
            var $children = $this.find('.submenu-pro');
            var $otherChildren = $this.siblings('li').find('.submenu-pro');
            var $childrenList = $children.children('.submenu-total');
            $this.on({
                'mouseenter': function () {
                    $children.css({ 'display': 'block', 'width': 221 * parseInt($childrenList.size()) });
                    $otherChildren.css('display', 'none');
                },
                'mouseleave': function () {
                    $children.css('display', 'none');
                }
            })
        });

        //member left
        $(".member-l-title").click(function(){
           $(this).parent(".member-l-list").toggleClass("m-current");
           $(this).parent(".member-l-list").find("ul").slideToggle()
        })
    })
    function sendMessage() {
        var mobile = $("#mobile").val();
        if (mobile == '') {
            alert("手机号码不能为空");
            $("#mobile").focus();
            return false;
        } else {
            if (!/^1[3|4|5|7|8][0-9]{9}$/.test(mobile)) {
                alert("手机号码格式不正确");
                $("#mobile").focus();
                return false;
            } else {
                SendVerify.sendMessage($("#btnSendCode"),mobile,'phone',"sms_changeinfo_tpl");
            }
        }
    }
</script>